﻿using Spire.Pdf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace laohan.Common.Common
{
    public partial class API
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="printerName"></param>
        /// <param name="fileName"></param>
        public static void PdfToPrint(string printerName, string fileName)
        {
            var doc = new PdfDocument();

            doc.LoadFromFile(fileName);

            doc.PrintSettings.PrinterName = printerName;

            doc.Print();
        }

        /// <summary>
        /// pdf打印（文件大小不能超过10页），超过10页会报错
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="copies">份数</param>
        public static void PdfToPrint(string fileName, short copies = 1)
        {
            var doc = new PdfDocument();

            doc.LoadFromFile(fileName);

            doc.PrintSettings.Copies = copies;

            doc.Print();
        }
    }
}